package br.museu.dao.basic;

import java.util.List;

import org.hibernate.Query;
import org.springframework.stereotype.Repository;

import br.museu.dao.basic.intefaces.IEventoDAO;
import br.museu.dao.generico.DAOGenerico;
import br.museu.model.Evento;

@Repository
public class EventoDAO extends DAOGenerico<Evento> implements IEventoDAO {

	public EventoDAO() {
	}

	@SuppressWarnings("unchecked")
	public List<Evento> getEventosMes() {
		String strQuery = "Select e From Evento where e.dtInicio = CURRENT_DATE()";

		Query query = getCurrentSession().createQuery(strQuery);

		return query.list();
	}

	@SuppressWarnings("unchecked")
	public List<Evento> getEventosDia() {
		String strQuery = "Select e From Evento where e.dtInicio = CURRENT_DATE() and e.dtFim = CURRENT_DATE()";

		Query query = getCurrentSession().createQuery(strQuery);

		return query.list();
	}

	public List<Evento> getEventosSemana() {
		return null;
	}

	public Evento consultarPorCodigo(Integer codigo) {
		String strQuery = "Select e From Evento e where e.codigo = :codigo";

		Query query = getCurrentSession().createQuery(strQuery);
		query.setInteger("codigo", codigo);

		return (Evento) query.uniqueResult();
	}

}
